package com.ts;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.net.InetAddress;

@SpringBootApplication
@Slf4j
@MapperScan("com.ts.mapper")
@EnableTransactionManagement //开启注解方式的事务管理
public class TsApplication {
    public static void main(String[] args) throws Exception {
        ConfigurableApplicationContext context = SpringApplication.run(TsApplication.class, args);
        log.info("后端服务已经启动");
        Environment env = context.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path", "");

        log.info("后端服务启动成功!");
        log.info("Knife4j文档: http://{}:{}{}/doc.html", ip, port, path);
        log.info("Swagger文档: http://{}:{}{}/swagger-ui.html", ip, port, path);
        log.info("OpenAPI JSON: http://{}:{}{}/v3/api-docs", ip, port, path);
    }
}